﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CommonLibrary.Common
{
    /// <summary>
    /// 类<c>DateUtil</c> 结果传递帮助类。
    /// </summary>
    public static class DateUtil
    {
        /// <summary>
        /// 获得当前日期 2009-07-01
        /// </summary>
        /// <returns></returns>
        public static string getDay()
        {
            DateTime dt = DateTime.Now;
            return dt.ToString("yyyy-MM-dd");
        }

        /// <summary>
        /// 当前月的第一天
        /// </summary>
        /// <returns></returns>
        public static DateTime getFirstDayOfMonth()
        {
            DateTime de = DateTime.Now.ToLocalTime();
            DateTime month = new DateTime(de.Year, de.Month, 1);
            return month;
        }

        /// <summary>
        /// 获得当前时间秒 2012-11-11 11:11:11
        /// </summary>
        /// <returns></returns>
        public static string getStandardTimeBySecond()
        {
            DateTime dt = DateTime.Now.ToLocalTime();
            return dt.ToString("yyyy-MM-dd HH:mm:ss");
        }

        /// <summary>
        /// 标准格式 2012-11-11 00:00:00
        /// </summary>
        /// <param name="dt"></param>
        /// <returns></returns>
        public static string getBeginTimeBySecond(DateTime dt)
        {
            return dt.ToString("yyyy-MM-dd ") + "00:00:00";
        }

        /// <summary>
        /// 标准格式 2012-11-11 23:59:59
        /// </summary>
        /// <param name="dt"></param>
        /// <returns></returns>
        public static string getEndTimeBySecond(DateTime dt)
        {
            return dt.ToString("yyyy-MM-dd ") + "23:59:59";
        }

        /// <summary>
        /// 获得当前时间 秒（yyyyMMddHHmmss） 
        /// </summary>
        /// <returns></returns>
        public static string getStringTimeBySecond()
        {
            DateTime dt = DateTime.Now.ToLocalTime();
            return dt.ToString("yyyyMMddHHmmss");
        }

    }
}
